<?php self::head(); ?>
<script type="text/javascript">
    iCMS.set('Vue.data', {
        type: "<?php echo $_GET['type']; ?>",
    });
</script>
<div class="content" id="<?php echo APP_MAINID; ?>">
    <div class="block">
        <div class="block-header block-header-default">
            <h3 class="block-title">搜索</h3>
        </div>
        <div class="block-content block-content-full">
            <form action="<?php echo iPHP_SELF; ?>"  method="get">
                <input type="hidden" name="app" value="<?php echo Admincp::$APP_NAME; ?>" />
                <div class="form-row">
                    <div class="input-group input-group-sm col-sm-6 col-lg-3 mt-1">
                        <div class="input-group-prepend"> <span class="input-group-text">类型</span></div>
                        <select v-model="type" name="type" id="type" class="form-control">
                            <option value=""></option>
                            <option value="all">所有类型</option>
                            <?php echo PropWidget::option(Role::$typeMap, 'type'); ?>
                        </select>
                    </div>
                    <div class="input-group input-group-sm col-sm-6 col-lg-3 mt-1">
                        <div class="input-group-prepend">
                            <label class="input-group-text" for="pageSize">每页</label>
                        </div>
                        <input class="form-control" type="text" name="pageSize" id="pageSize" value="<?php echo Paging::$pageSize; ?>" />
                        <div class="input-group-append">
                            <label class="input-group-text" for="pageSize">条记录</label>
                        </div>
                    </div>
                    <div class="input-group input-group-sm col-sm-6 col-lg-3 mt-1">
                        <div class="input-group-prepend">
                            <label class="input-group-text" for="keywords">关键字</label>
                        </div>
                        <input type="text" name="keywords" class="form-control" id="keywords" value="<?php echo $_GET['keywords']; ?>" />
                        <div class="input-group-append">
                            <button class="btn btn-primary" type="submit"><i class="fa fa-fw fa-search"></i> 搜 索</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="block">
        <div class="block-header">
            <h3 class="block-title">角色列表</h3>
        </div>
        <ul class="nav nav-tabs nav-tabs-block align-items-center" data-toggle="tabs" role="tablist">
            <li class="nav-item"><a class="nav-link <?php if (!isset($_GET['type'])) echo ' active'; ?>" href=" <?php echo self::url(" type=null"); ?>">全部</a></li>
            <?php foreach (Role::$typeMap as $key =>$value) { ?>
            <li class="nav-item">
                <a class="nav-link <?php if (isset($_GET['type']) && $_GET['type'] == $key) echo ' active'; ?>" href=" <?php echo self::url(" type=" . $key); ?>"><?php echo $value; ?></a>
            </li>
            <?php } ?>
        </ul>
        <div class="block-content p-0">
            <form action="<?php echo APP_URL; ?>&action=batch" method="POST" id="<?php echo APP_FORMID; ?>" target="iPHP_FRAME">
                <div class="table-responsive">
                    <table class="dataTable table text-nowrap table-hover table-striped table-vcenter font-size-sm mb-0">
                        <thead class="bg-light text-black">
                            <tr>
                                <th style="width: 36px;" class="align-middle">
                                    <div class="custom-control custom-checkbox">
                                        <input type="checkbox" class="custom-control-input" id="check-all" data-toggle="checkAll" data-target="#<?php echo APP_FORMID; ?>">
                                        <label class="custom-control-label" for="check-all"></label>
                                    </div>
                                </th>
                                <th>ID</th>
                                <th>名称</th>
                                <th>金币</th>
                                <th>积分</th>
                                <th>点数</th>
                                <th>免费</th>
                                <th>状态</th>
                                <th>类型</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if ($result) foreach ($result as $key => $value) {
                                $isSuperAdmin = Role::isSuper($value['id']);
                            ?>
                                <tr id="id<?php echo $value['id']; ?>">
                                    <td>
                                        <?php if (!$isSuperAdmin) {  ?>
                                            <div class="custom-control custom-checkbox">
                                                <input type="checkbox" class="custom-control-input" id="checkbox-<?php echo $value['id']; ?>" name="id[]" value="<?php echo $value['id']; ?>" />
                                                <label class="custom-control-label" for="checkbox-<?php echo $value['id']; ?>"></label>
                                            </div>
                                        <?php } ?>
                                    </td>
                                    <td><?php echo $value['id']; ?></td>
                                    <td>
                                        <input <?php $isSuperAdmin && print('disabled="disabled"') ?> type="text" name="data[<?php echo $value['id']; ?>][name]" class="form-control form-control-sm" value="<?php echo $value['name']; ?>" />
                                    </td>
                                    <td>
                                        <input <?php $isSuperAdmin && print('disabled="disabled"') ?> type="text" name="data[<?php echo $value['id']; ?>][money]" class="form-control form-control-sm" value="<?php echo $value['money']; ?>" />
                                    </td>
                                    <td>
                                        <input <?php $isSuperAdmin && print('disabled="disabled"') ?> type="text" name="data[<?php echo $value['id']; ?>][credit]" class="form-control form-control-sm" value="<?php echo $value['credit']; ?>" />
                                    </td>
                                    <td>
                                        <input <?php $isSuperAdmin && print('disabled="disabled"') ?> type="text" name="data[<?php echo $value['id']; ?>][scores]" class="form-control form-control-sm" value="<?php echo $value['scores']; ?>" />
                                    </td>
                                    <td>
                                        <input <?php $isSuperAdmin && print('disabled="disabled"') ?> type="text" name="data[<?php echo $value['id']; ?>][free]" class="form-control form-control-sm" value="<?php echo $value['free']; ?>" />
                                    </td>
                                    <td>
                                        <input <?php $isSuperAdmin && print('disabled="disabled"') ?> type="checkbox" data-toggle="switch" data-size="small" name="data[<?php echo $value['id']; ?>][status]" <?php echo $value['status'] ? 'checked' : ''; ?> />
                                    </td>
                                    <td>
                                        <span class="badge badge-info"><?php echo Role::$typeMap[$value['type']]; ?></span>
                                    </td>
                                    <td>
                                        <div class="btn-group btn-group-sm">
                                            <?php if (!$isSuperAdmin) { ?>
                                                <?php if ($value['type'] == Role::MEMBER) {  ?>
                                                    <a href="<?php echo APP_URL; ?>&do=job&id=<?php echo $value['id']; ?>" class="btn btn-alt-primary" title="统计"><i class="fa fa-fw fa-chart-bar"></i></a>
                                                    <a href="<?php echo APP_URL; ?>&do=access_app&id=<?php echo $value['id']; ?>" class="btn btn-alt-primary" title="后台权限"><i class="fa fa-fw fa-crown"></i></a>
                                                    <a href="<?php echo APP_URL; ?>&do=access_node&id=<?php echo $value['id']; ?>" class="btn btn-alt-primary" title="栏目权限"><i class="fa fa-fw fa-sitemap"></i> </a>
                                                <?php } ?>
                                                <a href="<?php echo APP_URL; ?>&do=add&id=<?php echo $value['id']; ?>" class="btn btn-alt-primary" title="编辑"><i class="fa fa-fw fa-pencil-alt"></i></a>
                                                <a href="<?php echo APP_URL; ?>&do=copy&id=<?php echo $value['id']; ?>" class="btn btn-alt-primary" title="复制"><i class="fa fa-fw fa-copy"></i></a>
                                                <a href="<?php echo APP_URL; ?>&action=delete&id=<?php echo $value['id']; ?>" target="iPHP_FRAME" class="del btn btn-alt-primary" title='永久删除' data-action="delete"><i class="fa fa-fw fa-trash-alt"></i></a>
                                            <?php } ?>
                                        </div>
                                    </td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
                <?php self::formFoot(); ?>
            </form>
        </div>
    </div>
</div>
<?php self::foot(); ?>